package com.bss.model;

// Generated Oct 27, 2011 10:37:49 PM by Hibernate Tools 3.3.0.GA

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotNull;

import com.bss.AbstractEntity;

/**
 * Bed generated by hbm2java
 */
@Entity
@Table(name = "bed")
public class Bed extends AbstractEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = -4947887871367868371L;

	private int id;

	private BedType bedType = new BedType();

	private Room room = new Room();

	private int bedNumber;

	private Set<BedBooking> bedBookings = new HashSet<BedBooking>(0);

	@Transient
	private boolean occupied;

	private int proposedRate;

	@Id
	@Column(name = "id", unique = true, nullable = false)
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Integer getId() {
		return this.id;
	}

	public void setId(final Integer id) {
		this.id = id;
	}

	@NotNull(message = "{bed.bedType.NotNull}")
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "idBedType")
	public BedType getBedType() {
		return this.bedType;
	}

	public void setBedType(final BedType bedtype) {
		this.bedType = bedtype;
	}

	@NotNull(message = "{bed.room.NotNull}")
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "idRoom")
	public Room getRoom() {
		return this.room;
	}

	public void setRoom(final Room room) {
		this.room = room;
	}

	public void setOccupied(final boolean occupied) {
		this.occupied = occupied;
	}

	@Transient
	public boolean isOccupied() {
		return this.occupied;
	}

	public void setBedNumber(final int bedNumber) {
		this.bedNumber = bedNumber;
	}

	@DecimalMin("1")
	@NotNull(message = "{bed.room.NotNull}")
	@Column(name = "bedNumber")
	public int getBedNumber() {
		return this.bedNumber;
	}

	public void setBedBookings(final Set<BedBooking> bedBookings) {
		this.bedBookings = bedBookings;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "bed")
	public Set<BedBooking> getBedBookings() {
		return this.bedBookings;
	}

	public void setProposedRate(final int proposedRate) {
		this.proposedRate = proposedRate;
	}

	@Transient
	public int getProposedRate() {
		return this.proposedRate;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "date", length = 19)
	public Date getDate() {
		return this.date;
	}

	@Transient
	public BedBooking getCurrentBooking() {
		for (BedBooking bedBooking : this.getBedBookings()) {
			return bedBooking;
		}
		return null;
	}

	public String name() {
		// TODO Auto-generated method stub
		return null;
	}

}
